package com.wty.design.creational.builder;

public class Course {
    private String courseName;
    private String coursePPT;
    private String courseVideo;
    private String courseArticle;

    public Course(String courseName, String coursePPT, String courseVideo, String courseArticle) {
        this.courseName = courseName;
        this.coursePPT = coursePPT;
        this.courseVideo = courseVideo;
        this.courseArticle = courseArticle;
    }

    public String getCourseName() {
        return courseName;
    }

    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }

    public String getCoursePPT() {
        return coursePPT;
    }

    public void setCoursePPT(String coursePPT) {
        this.coursePPT = coursePPT;
    }

    public String getCourseVideo() {
        return courseVideo;
    }

    public void setCourseVideo(String courseVideo) {
        this.courseVideo = courseVideo;
    }

    public String getCourseArticle() {
        return courseArticle;
    }


    public void setCourseArticle(String courseArticle) {
        this.courseArticle = courseArticle;
    }

    @Override
    public String toString() {
        return "Course{" +
                "courseName='" + courseName + '\'' +
                ", coursePPT='" + coursePPT + '\'' +
                ", courseVideo='" + courseVideo + '\'' +
                ", courseArticle='" + courseArticle + '\'' +
                '}';
    }

    //获取builder对象
    public static CourseBuilder builder(){
        //因为内部类声明为static才能这样，否则要先创建Course的对象
        return new CourseBuilder();
    }




    public static class CourseBuilder{
        private String courseName;
        private String coursePPT;
        private String courseVideo;
        private String courseArticle;

        //链式调用
        public CourseBuilder courseName(String courseName){
            this.courseName=courseName;
            return this;
        }
        public CourseBuilder coursePPT(String coursePPT){
            this.coursePPT=coursePPT;
            return this;
        }
        public CourseBuilder courseVideo(String courseVideo){
            this.courseVideo=courseVideo;
            return this;
        }
        public CourseBuilder courseArticle(String courseArticle){
            this.courseArticle=courseArticle;
            return this;
        }

        //建造者返回一个要建造的对象
        public Course build(){
            return new Course(courseName,coursePPT,courseVideo,courseArticle);
        }
    }
}
